package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class CollectionToArray {
    public static void main(String[] args) {
        Collection<String> c =new ArrayList<>();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        System.out.println(c);
        //若参数数组元素的个数==集合元素个数，正常转
        //若参数数组的元素个数<集合元素的个数，正常转
        //若参数数组的元素个数>集合元素的个数，正常转，同时在末尾补默认值
        String[] array = c.toArray(new String[8]);
        System.out.println(Arrays.toString(array));


    }
}
